package com.zoranjoka.chordis.pages.add;

import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.hibernate.annotations.CommitAfter;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.hibernate.Session;

import com.zoranjoka.chordis.dao.ArtistDAO;
import com.zoranjoka.chordis.entities.ArtistBean;
import com.zoranjoka.chordis.pages.Artist;

public class AddArtist {
	@Inject
	private ArtistDAO dataArtist;
	
	@Property
	private ArtistBean artistBean;
	@Property
	private String name;
	
	void onActivate()
	{
		artistBean = new ArtistBean();
	}
//	
//	
	@CommitAfter
	Object onSubmitFromNewArtistForm(){
		artistBean.setName(name);
		dataArtist.save(artistBean);
		return Artist.class;
	}
}
